package com.imooc.uaa.validation;

import com.imooc.uaa.annotation.ValidPasswordMatch;
import com.imooc.uaa.domain.dto.UserDto;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class PasswordMatch implements ConstraintValidator<ValidPasswordMatch, UserDto> {
    @Override
    public void initialize(ValidPasswordMatch constraintAnnotation) {

    }

    @Override
    public boolean isValid(UserDto userDto, ConstraintValidatorContext context) {
        return userDto.getPassword().equals(userDto.getMatchingPassword());
    }
}
